package com.glodon.paas.account.security.oauth2.controller;

import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;
import java.util.TreeMap;

/**
 * Display code or token, when authorization succeeded.
 *
 * @author Don Li
 */
@Controller
public class AuthorizationSuccessService {

    @RequestMapping(value = "/oauth2/show_code", method = RequestMethod.GET)
    public ModelAndView displayCode(@RequestParam("code") String code, @RequestParam("state") String state) {
        Map<String, String> model = new TreeMap<String, String>();
        model.put("code", code);
        model.put("state", state);
        return new ModelAndView("code", model);
    }

    @RequestMapping(value = "/oauth2/show_token", method = RequestMethod.GET)
    @ResponseStatus(HttpStatus.OK)
    public void displayToken() {
        // nothing to do
    }
}
